package com.zqp.web.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.zqp.exception.UserNotExistException;

/**
* @author zqp
* @date 2017年12月19日 
* @description  处理controller  异常 
*/
@ControllerAdvice
public class ControllerExceptionHandler {

	@ExceptionHandler(UserNotExistException.class)
	@ResponseBody
	@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
	public Map<String, Object> handlerUserNotExistException(UserNotExistException ex){
		Map<String, Object> result =new HashMap<>();
		result.put("id", ex.getId());
		result.put("message", ex.getMessage());
		
		return result;
	}
}
